var connection = require("../mysqldb");

/* 
var deleteSql = {
  init: function (res, data) {
    console.log("执行了删除数据库操作");
    var sql = "DELETE FROM hhpwuser WHERE user='" + data.user + "'";
    connection.query(sql, function (err, result) {
      console.log(sql);
      if (err) {
        console.log('[SELECT ERROR] - ', err.message);
        return;
      } else {
        console.log("删除成功");
        res.write("删除成功");
        res.end();
      }

    })
  }
} */

class deleteSql {
  constructor() { }
  init(res, data) {
    console.log("执行了删除数据库操作");
    var sql = "DELETE FROM hhpwuser WHERE user='" + data.user + "'";
    connection.query(sql, (err, result) => {
      console.log(sql);
      if (err) {
        console.log('[SELECT ERROR] - ', err.message);
        return;
      } else {
        console.log("删除成功");
        res.write("删除成功");
        res.end();
      }

    })
  }
}

module.exports = new deleteSql;